PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Repeat Until

The Repeat Until form of the Repeat statement repeats a group of statements until a particular condition, specified in a Boolean expression, is met.

SYNTAX
repeat until Boolean
    [ statement ]...
end [ repeat ]

where

Boolean is an expression whose value is true or false . The statements in the loop are repeated until Boolean becomes true . If Boolean is true when entering the loop, the statements in the loop are not executed.

statement is any AppleScript statement.

EXAMPLE

The following example is based on Figure 2-4, which shows a script that copies information from a database to a spreadsheet. The script uses the Repeat Until form of the Repeat statement, copying an inventory count from each database record to a spreadsheet cell until a loop variable exceeds the number of records. The script assumes the database and spreadsheet files are already open.

tell application "FileMaker Pro"
    set numberRecords to count records of document "Inventory DB"
    set loopCount to 1
    repeat until loopCount > numberRecords
        copy cell "Count" of record loopCount ¬
            of document "Inventory DB" to partCount
        set cellName to "B" & ((loopCount + 1) as string)
        tell application "AppleWorks"
            set cell cellName of spreadsheet of document ¬
                "Spreadsheet" to partCount as string
        end tell
        set loopCount to loopCount + 1
    end repeat
end tell

© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)